//
//  PhoneTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/2.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "PhoneTableViewCell.h"

@implementation PhoneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = rgba(27,44,81,1);
        [self masLayoutSubview];
    }
    return self;
}

- (void)didClickCallButton
{
    if (self.CallBlock)
    {
        self.CallBlock();
    }
}

- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self.contentView;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
        [_nameLabel setFont:fontCommonSize];
        [_nameLabel setTextColor:[UIColor whiteColor]];
    }
    return _nameLabel;
}
- (UILabel *)phoneLabel
{
    if(!_phoneLabel)
    {
        UIView *superView = self.contentView;
        _phoneLabel = [[UILabel alloc]init];
        [superView addSubview:_phoneLabel];
        [_phoneLabel setFont:fontWithSize(14)];
        [_phoneLabel setTextColor:rgba(88,111,161,1)];
    }
    return _phoneLabel;
}
- (UIButton *)callButton
{
    if(!_callButton)
    {
        UIView *superView = self.contentView;
        _callButton = [[UIButton alloc]init];
        [superView addSubview:_callButton];
        [_callButton setImage:imageWithName(@"icon_phone call 11") forState:UIControlStateNormal];
//        [_callButton setBackgroundImage:imageWithName(@"icon_phone call 11") forState:UIControlStateNormal];
        [_callButton addTarget:self action:@selector(didClickCallButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _callButton;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;

    [self.callButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1080Width(40));
        make.height.width.mas_equalTo(px1920Height(120));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(40));
        make.right.mas_equalTo(self.callButton.mas_left);
        make.bottom.mas_equalTo(superView.mas_centerY).with.offset(-px1920Height(10));
    }];
    
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(40));
        make.right.mas_equalTo(self.callButton.mas_left);
        make.top.mas_equalTo(superView.mas_centerY).with.offset(px1920Height(10));
        
    }];
}

@end
